package edu.cityu.cs.hk.datastructures;
/**
 * Interface for a vector.
 * @author Michael Goodrich, Roberto Tamassia
 */
//begin#fragment Vector
public interface Vector {
  /** Returns the number of elements in the vector. */
  public int size();
  /** Returns whether the vector is empty. */
  public boolean isEmpty();
  /** Returns the element stored at the given rank. */
//end#fragment Vector
  /** Returns the element stored at the given rank. 
   * @param r Rank to query
   * @throws BoundaryViolationException if <tt>r</tt> < 0 or
   * <tt>r</tt> > {@link #size()} - 1
   */
//begin#fragment Vector
  public Object elemAtRank(int r) throws BoundaryViolationException;
  /** Replaces the element stored at the given rank. */
//end#fragment Vector
  /** Replaces the element stored at the given rank.
   * @param r Rank at which to replace
   * @throws BoundaryViolationException if <tt>r</tt> < 0 or
   * <tt>r</tt> > {@link #size()} - 1
   */
//begin#fragment Vector
  public Object replaceAtRank(int r, Object e) throws BoundaryViolationException;
  /** Inserts an element at the given rank. */
//end#fragment Vector
  /** Inserts an element at the given rank.
   * @param r Rank at which to replace
   * @throws BoundaryViolationException if <tt>r</tt> < 0 or
   * <tt>r</tt> > {@link #size()}
   */
//begin#fragment Vector
  public void insertAtRank(int r, Object e) throws BoundaryViolationException;
  /** Removes the element stored at the given rank. */
//end#fragment Vector
  /** Removes the element stored at the given rank.
   * @param r Rank at which to replace
   * @throws BoundaryViolationException if <tt>r</tt> < 0 or
   * <tt>r</tt> > {@link #size()} - 1
   */
//begin#fragment Vector
  public Object removeAtRank(int r) throws BoundaryViolationException;
}
//end#fragment Vector
